{include file="public/head"/}
<link rel="stylesheet" href="__PUBLIC__phone/css/passwd.css"/>
<body>
<!--头部-->
<header id="headers">
    <div class="container">
        <div class="row">
            <div class="col-xs-12">
                <a href="javascript:;" class="leftRuted glyphicon glyphicon-menu-left pull-left" ></a>
                <p>修改密码</p>
            </div>
        </div>
    </div>
</header>
<!-- 个人资料 -->
<div class="personData normalBox">
    <div class="normarWrap orderWrap container">
        <form id="form">
            <div class="form-group">
                <label for="lpwd">原密码：</label>
                <input type="password" id="lpwd" name="opasswd" class="form-control"/>
            </div>
            <div class="form-group">
                <label for="pwd">新密码：</label>
                <input type="password" id="pwd" name="passwd" class="form-control"/>
            </div>
            <div class="form-group">
                <label for="repwd">重复密码：</label>
                <input type="password" id="repwd" name="cpasswd" class="form-control"/>
            </div>
            <div class="pwdWrap">
                <p></p>
            </div>
            <div class="form-group subwrap">
                <button type="button" class="btn submitbtn">保存</button>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        var flag = true;
        $('.subwrap').on('click','button',function(){
            if(!flag){   // 防止重复点击
                return false;
            }
            flag = false;
            // 获取数据
            var conf = $('#form').serializeArray();
            var checkPasswd = /[\w]{6,16}/;
            for(var i in conf){
                if(conf[i]['name'] != 'cpasswd' && !checkPasswd.test(conf[i]['value'])){   // 验证密码
                    $('.pwdWrap p').text('密码由6-16位字母数字下划线组成');
                    $('.pwdWrap').show();
                    flag = true;
                    return false;
                }
                if(conf[i]['name'] == 'cpasswd' && conf[i]['value'] != conf[i-1]['value']){   // 验证密码一致性
                    $('.pwdWrap p').text('确认密码和新密码不一致');
                    $('.pwdWrap').show();
                    flag = true;
                    return false;
                }
            }
            // 提交
            $.post("{:url('/home/Personal/submitModify')}",conf,function(data){
                if(data.code == '0'){
                    $('#form')[0].reset();
                    $('.pwdWrap').hide();
                    reminder(data.msg);
                } else {
                    $('.pwdWrap p').text(data.msg);
                    $('.pwdWrap').show();
                }
                flag = true;
            })
        })
    })
</script>
</body>
</html>